<?php
class Admin_advertisements_model extends CI_Model {

	function __construct(){
		parent::__construct();
	}

	function getAdvertisements($where=""){
		$query = $this->db->query("SELECT * FROM mlme_advertisements $where");
		return $query;
	}

	function getAdvertisements_limited($start_row=0, $limit=10){
		$query = $this->db->query("SELECT * FROM mlme_advertisements ORDER BY advertisementsid DESC LIMIT $start_row, $limit");
		return $query->result();
	}

	function addAdvertisements($data){
		$data['date_added'] = date('y-m-d h:m:s');
		$data['date_updated'] = date('y-m-d h:m:s');
//		$new_advertisements = array(
//			'advertisementsid' => '',
//			'banner' => '',
//			'name' =>  $this->input->post('ads_name'),
//			'section' =>  $this->input->post('ads_section'),
//			'date_added' => date('F j, Y'),
//			'date_updated' => date('F j, Y'),
//			'status' => $this->input->post('ads_status')
//		);
		return $this->db->insert('mlme_advertisements', $data);
	}

	function updateAdvertisements($post,$id){
		$post['date_updated'] = date('y-m-d h:m:s');
		//$advertisementsid = $this->db->query("SELECT advertisementsid FROM mlme_advertisements WHERE advertisementsid = ".$id);
		$this->db->where('advertisementsid', $id);
		$update = $this->db->update('mlme_advertisements', $post);
		return $update;
	}



}// end of Model